package com.tlkg.qa.redistest.live;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

//import org.slf4j.LoggerFactory;

//import ch.qos.logback.classic.LoggerContext;
//import ch.qos.logback.classic.joran.JoranConfigurator;
//import ch.qos.logback.core.joran.spi.JoranException;
//import ch.qos.logback.core.util.StatusPrinter;

/**
 * 加载配置文件
 * 
 * @author Feng
 * 
 */
public class PropertiesUtil {

	private static Properties instance = null;

	public static final String port = "port";
	public static final String host = "host";

	public static final String port2 = "port2";
	public static final String host2 = "host2";

	public static final String roomId = "roomId";
	public static final String sessionId = "sessionId";
	public static final String UserId = "UserId";

	public static final String sessionId1 = "sessionId1";
	public static final String UserId1 = "UserId1";

	public static final String Test = "Test";
	public static final String begin = "begin";
	public static final String end = "end";
	
	public static final String wft = "writeFreeTime";
	
	private PropertiesUtil() {
	}

	public static Properties getInstance() {
		try {
			if (instance == null) {
				instance = new Properties();
				InputStream is = PropertiesUtil.class.getResourceAsStream("config.properties");
				instance.load(is);
//				instance.load(new FileInputStream("config.properties"));
			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return instance;
	}

//	public static void load(String externalConfigFileLocation) throws IOException, JoranException {
//
////		LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
//
//		File externalConfigFile = new File(externalConfigFileLocation);
//
//		if (!externalConfigFile.exists()) {
//
//			throw new IOException("Logback External Config File Parameter does not reference a file that exists");
//
//		} else {
//
//			if (!externalConfigFile.isFile()) {
//				throw new IOException("Logback External Config File Parameter exists, but does not reference a file");
//
//			} else {
//
//				if (!externalConfigFile.canRead()) {
//					throw new IOException("Logback External Config File exists and is a file, but cannot be read.");
//
//				} else {
//
////					JoranConfigurator configurator = new JoranConfigurator();
////					configurator.setContext(lc);
////					lc.reset();
////					configurator.doConfigure(externalConfigFileLocation);
//
////					StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
//				}
//
//			}
//
//		}

//	}
}
